require 'starling'


s = Starling.new("127.0.0.1:22122")

Sec2Host = {
		"c10"=>'c2430',
		"c11"=>'c1784',
		"c12"=>'c2526',
		"c13"=>'c05035',
		"c4"=>'c1038',
		"c5"=>'c1138',
		"c6"=>'c2139',
		"c7"=>'c1544',
		"c8"=>'c21a61',
		"c9"=>'c2221',
		"t10"=>'t28a25',
		"t11"=>'t02a29',
		"t12"=>'t28b19',
		"t13"=>'t30a15',
		"t14"=>'t28c48',
		"t15"=>'t3626',
		"t16"=>'t21027',
		"t3"=>'t0438',
		"t5"=>'t0638',
		"t6"=>'t0559',
		"t7"=>'t1944',
		"t8"=>'t0140',
		"t9"=>'t2840',
		"u1"=>'u0716'
}

# return > 0 => exists
# else       => not exists
def check(sec,gcid)
		host=Sec2Host[sec]
		return false if host==nil;

		cmd="ssh root@#{host}.sandai.net \"gfs -ls /gdrive/resource/#{gcid[0...2]}/#{gcid[-2..-1]}/#{gcid}\""
#		Log.debug "gfs cmd=>#{cmd}"
		rv=`#{cmd}`
#		Log.debug "gfs ls rv => #{rv}"
		puts "gfs cmd => #{cmd},rv=>#{rv}"
		return true if rv.length > 0
		return false
end


loop do
		gcid,sec = s.get("gcid_sec")
		rv = check(gcid,sec)
		puts "#{sec}=>#{gcid} exists" if rv
		puts "#{sec}=>#{gcid} not exists" if not rv
end
